- /* wait.h by K.Tsuru */
- #ifndef WAIT_H
- #define WAIT_H
- #define CONIO_EXIST 0 // Change '1' if your compiler has "conio.h".
-
- #include <iostream>
- #include <stdlib.h>
- #include <stdio.h>
- using namespace std; // ver. 2.30
-
- #if CONIO_EXIST
-
- /***************************
- Non ANSI functions are used.
- It needs "conio.h"
- *****************************/
- #include <conio.h>
-
- inline void ErrorPuts(const char* msg){
- fprintf(stderr, "%s\n", msg);
- }
- inline void ErrorPut(const char* msg){
- fprintf(stderr, "%s", msg);
- }
- inline void Wait(const char* msg = NULL){
- if(msg != NULL) ErrorPuts(msg);
- ErrorPuts("Press Esc key to abort / another to continue.");
- if(kbhit()) getch();
- if( getch() == 0x1b ){ // conio.h
- ErrorPuts("Aborted.");
- exit(EXIT_FAILURE);
- }
- }
- inline void Ending(){
- ErrorPuts("Program ended. Hit any key.");
- if(kbhit()) getch();
- getch();
- }
- #else //CONIO_EXIST = 0
- /********************************
- ANSI C version
- Only ANSI functions are used.
- *********************************/
- inline void ErrorPuts(const char* const msg){ cerr << msg << endl; }
- inline void ErrorPut(const char* const msg) { cerr << msg; }
- inline void Wait(const char* msg = NULL){
- if(msg != NULL) ErrorPuts(msg);
- ErrorPuts("Press 'a' and <Enter> key to abort / <Enter> key to continue.");
- if(getchar() == 'a'){
- ErrorPuts("Aborted.");
- exit(EXIT_FAILURE);
- }
- }
- inline void Wait(const string& msg){
- Wait(msg.c_str());
- }
- inline void Ending(){
- ErrorPuts("Program ended. Hit any key.");
- getchar();
- }
- #endif // CONIO_EXIST
- #endif // WAIT_H
wait.h : last modifiled at 2017/02/25 10:30:42(1,589 bytes)
created at 2016/04/11 11:18:59
The creation time of this html file is 2017/10/11 16:07:52 (Wed Oct 11 16:07:52 2017).